package com.wjc.demo.filter;

import org.springframework.core.annotation.Order;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

/**
 * @ Description：TODO
 * @ Author：wzj
 * @ Date：2019/3/10 15:46
 */
//@Order(value = 3)多个filter时 根据filter的类名排序，使用@Order定义执行顺序目前发现无效
@WebFilter(filterName = "firstFilter",urlPatterns = "/*")
public class FirstFilter implements Filter {
    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        System.out.println("FirstFilter doFilter Start");
        filterChain.doFilter(servletRequest,servletResponse);
        System.out.println("FirstFilter doFilter End");
    }

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.println("FirstFilter Init");
    }

    @Override
    public void destroy() {
        System.out.println("FirstFilter destroy");
    }
}
